Added EntityTag.State Property for Armadillo Rolling#2802
Added EntityTag.State Property for Armadillo Rolling#2802tal5 merged 7 commits intoDenizenScript:devfrom
Conversation
| public ElementTag getArmadilloState(Armadillo entity) { | ||
| throw new UnsupportedOperationException(); | ||
| } |
There was a problem hiding this comment.
Should create an "API" enum of our own and take/return that (see for example BlockHelper#get/setPushReaction), that way we don't directly depend on Mojang's internal enum names and can easily notice once there's changes and/or avoid them entirely because we control the naming.
|
|
||
| @Override | ||
| public void setPropertyValue(ElementTag param, Mechanism mechanism) { | ||
| NMSHandler.entityHelper.setArmadilloState(as(Armadillo.class), mechanism, param); |
There was a problem hiding this comment.
Once we have our own enum, can handle input checking here instead of in each NMS impl
|
|
||
| @Override | ||
| public ElementTag getArmadilloState(org.bukkit.entity.Armadillo entity) { | ||
| net.minecraft.world.entity.animal.armadillo.Armadillo armadillo = (Armadillo) ((CraftEntity) entity).getHandle(); |
There was a problem hiding this comment.
Why are you using the FQN here if you have it imported & use it normally in the cast?
| case ROLLING -> Armadillo.ArmadilloState.ROLLING; | ||
| case SCARED -> Armadillo.ArmadilloState.SCARED; | ||
| case UNROLLING -> Armadillo.ArmadilloState.UNROLLING; | ||
| }); |
plugin/src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityState.java
Show resolved
Hide resolved
| // @description | ||
| // Controls the current state of an armadillo. | ||
| // Valid states are IDLE, ROLLING, SCARED, and UNROLLING. | ||
| // The entity may roll or unroll due to normal vanilla conditions. If this is not desired, disable <@link mechanism EntityTag.has_ai>. |
There was a problem hiding this comment.
Technically @link property is nicer here for if we ever make these more concrete than just redirecting to a mech link.
|
|
||
| @Override | ||
| public boolean isDefaultValue(ElementTag val) { | ||
| return NMSHandler.entityHelper.getArmadilloState(as(Armadillo.class)).equals(ArmadilloState.IDLE); |
There was a problem hiding this comment.
Ideally this should check the value for being idle I think, technically it doesn't strictly always check the current value here (as in, in the future this might be used to check if some other random element is the default value).
Redo of #2758 using NMS rather than Spigot's method.